﻿/*
    This file is part of ndoctor-statistics.

    ndoctor-statistics is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ndoctor-statistics is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ndoctor-statistics.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Probel.NDoctor.Statistics.Domain;

namespace Probel.NDoctor.Statistics.RepositoriesImpl
{
    public class MemoryRepository : IRepository
    {
        #region Fields

        private readonly List<StatisticEntry> statistics;
        private readonly List<Application> users;

        #endregion Fields

        #region Constructors

        public MemoryRepository(IEnumerable<Application> users, IEnumerable<StatisticEntry> stat)
        {
            this.users = new List<Application>(users);
            this.statistics = new List<StatisticEntry>(stat);
        }

        #endregion Constructors

        #region Properties

        public IEnumerable<StatisticEntry> Statistics
        {
            get { return this.statistics; }
        }

        public IEnumerable<Application> Users
        {
            get { return this.users; }
        }

        #endregion Properties

        #region Methods

        public void Insert(IEnumerable<StatisticEntry> statistics)
        {
            var factory = Queries.ForUnitTest(this);

            this.statistics.AddRange(statistics);
        }

        public void Insert(Application user)
        {
            this.users.Add(user);
        }

        #endregion Methods
    }
}
